package com.ruoyi.web.timer;

import com.ruoyi.web.controller.dto.OrderVo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class RedisTimer {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Scheduled(cron = "0/2 * * * * ?")
    public void checkRedis(){
        OrderVo redisOrderVo = (OrderVo) redisTemplate.opsForValue().get("redisOrderVo");
        if (redisOrderVo!=null){
            rabbitTemplate.convertAndSend("2010a",redisOrderVo);

        }

    }

}
